package priv.yiyuan.example.composite;

/**
 * 具体文档生成器
 * <p>
 * 生成器模式 具体生成器
 *
 * @author YiYuan
 * @data 2025/8/28
 * @apoNote
 */
public class ConcreteDocumentBuilder implements DocumentBuilder {

    private DocumentComposite document = new DocumentComposite();

    @Override
    public DocumentBuilder addHeading(String text, int level) {
        document.add(new Heading(text, level));
        return this;
    }

    @Override
    public DocumentBuilder addParagraph(String text) {
        document.add(new Paragraph(text));
        return this;
    }

    @Override
    public DocumentBuilder addComposite(DocumentComponent composite) {
        document.add(composite);
        return this;
    }

    @Override
    public DocumentComponent build() {
        return document;
    }
}
